#ifndef FOCMAINWINDOW_H
#define FOCMAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>
#include <QTcpSocket>
#include <QTcpServer>
#include <QTimer>
#include "parser.h"

#define MAX_MESSAGE_LEN    (2000)

QT_BEGIN_NAMESPACE
namespace Ui { class FocMainWindow; }
QT_END_NAMESPACE

class FocMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    FocMainWindow(QWidget *parent = nullptr);
    ~FocMainWindow();

    void init_signal_and_slot();
    void init_var();
    void init_ui();

private:
    Ui::FocMainWindow *ui;
    parser_st *parser;
    QSerialPort *serial;
    QTcpServer *tcp_server;
    QTcpSocket *tcp_socket;
    QTimer *protocol_tim;

private slots:
    void slot_connect_deal();
    void slot_connect_method_changed(const QString&);
    void tcp_server_connect();
    void tcp_connected();
    void tcp_disconnected();
    // void tcp_readyRead();
    void tcp_ready_read();
    void protocol_timer_out();
};
#endif // FOCMAINWINDOW_H
